#include "StdAfx.h"
#include "DX10MaterialIndexBuffer.h"
#include "DX10ObjMesh.h"


DX10MaterialIndexBuffer::DX10MaterialIndexBuffer(void):m_pIndexBuffer(NULL),m_pDiffuseTextureRV(NULL),m_pNormalTextureRV(NULL)
{
}

DX10MaterialIndexBuffer::~DX10MaterialIndexBuffer(void)
{
	SafeRelease(m_pIndexBuffer);
}

void DX10MaterialIndexBuffer::Draw(ID3D10Device* pDevice, const DX10ObjMesh* parent,ID3D10EffectPass* pass) const{
	if ( m_pDiffuseTextureRV )
		parent->SetDiffuseTexture(m_pDiffuseTextureRV);
	if ( m_pNormalTextureRV )
		parent->SetNormalMapTexture(m_pNormalTextureRV);
	pass->Apply(0);
	pDevice->IASetIndexBuffer( m_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0 );
	pDevice->DrawIndexed( m_NumIndices, 0, 0 );
}
